import request from '@/router/axios'

export function fetchOrg(query) {
  return request({
    url: '/admin/org/tree',
    method: 'get',
    params: query
  })
}
export function roleupdateOrg(obj){
  return request({
    url: '/admin/roleorg/updateRoleOrg',
    method: 'put',
    data:obj
  })
}
export function roleorgQuery(id){
  return request({
    url: '/admin/roleorg/'+id,
    method: 'get'
  })
}
export function addObj(obj) {
  return request({
    url: '/admin/org/',
    method: 'post',
    data: obj
  })
}
export function orgRoleList(query) {
  return request({
    url: '/admin/org/tree',
    method: 'get',
    params: query
  })
}
export function getObj(id) {
  return request({
    url: '/admin/org/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return request({
    url: '/admin/org/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
  console.log(obj)
  return request({
    url: '/admin/org/',
    method: 'put',
    data: obj
  })
}
export function getOrgQuery(query) {
  console.log(query)
  return request({
    url: '/admin/org/details',
    method:'get',
    params: query
  })
}
//获取登录用户的组织树
export function getLoginUserOrgTree(userId) {
  return request({
    url: '/admin/org/getLoginUserOrgTree/'+userId,
    method:'get'
  })
}
export function getUserObj(id){
  return request({
    url: '/admin/user/getUserByOrgId/'+id,
    method:'get'
  })
}

